<template>
  <div>
<h2>房型添加</h2>
  </div>
  <table border="1">
    <tr>
      <td>房号</td>
      <td>
        <input type="number" v-model="state.roomNumber">
      </td>
    </tr>
    <tr>
      <td>房型名称</td>
      <td>
        <input type="text" v-model="state.roomName">
      </td>
    </tr>
    
    <tr>
      <td>房间数量</td>
      <td>
        <input type="text" v-model="state.roomNum">
      </td>
    </tr>
    <tr>
      <td>门市价</td>
      <td>
        <input type="text" v-model="state.roomPrice">
      </td>
    </tr>
    <tr>
      <td></td>
      <td>
        <input type="button" value="添加" @click="add">
      </td>
    </tr>
  </table>
</template>

<script setup lang="ts">

import axios from 'axios';
import{reactive,toRefs,onMounted}from'vue'
import { useRoute,useRouter } from 'vue-router';
let router=useRouter();
let route=useRoute();
let data=reactive({
  state:{
  roomNumber: '',
  roomName: '',
  roomNum: '',
  roomPrice: ''
  }
})
let {state}=toRefs(data)
function add()
{
  let obj={
    roomNumber: state.value.roomNumber,
  roomName: state.value.roomName,
  roomNum: state.value.roomNum,
  roomPrice: state.value.roomPrice
  }
  axios({
    url:'/api/RoomType/RoomAdd',
    method:'post',
    data:obj
  })
  .then(res=>{
if(res.data.data==1)
{
  alert("添加成功")
router.push("../show")
}
  })
  .catch(err=>{
  })
}
</script>

<style scoped>

</style>